package com.mingzhi.rabbitextensiondemo.controller;

import com.mingzhi.rabbitextensiondemo.constant.Constants;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/producer")
public class AckController {

    @Autowired
    private RabbitTemplate rabbitTmplate;

    @RequestMapping("/ack")
    public String ack() {
        //发送消息
        //参数1：交换机名称，参数2：routingKey，参数3：消息内容
        rabbitTmplate.convertAndSend(Constants.ACK_EXCHANGE,
                "ack",
                "consumer ack mode test.....");
        return "发送成功";
    }


    @RequestMapping("/returns")
    public String returns() {
        //关联数据 correlationData

        return "发送成功";
    }
}
